<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<label>请输入被除数：</label>
		<input type="text" id="c1" />
		<label>请输入除数：</label>
		<input type="text" id="c2" />
		<input type="button" value="确定" onclick="aa()" />
		<br />
		<label>商为：</label>
		<span id="shang"></span>
		<script type="text/javascript">
			function divide(c1, c2) {
				var s;
				s = c1 / c2;
				if(s == "Infinity")	throw "除数不能为0";
				else if(isNaN(s)) throw "算式不合法";
				return s;
			}			
			function aa () {
				var c1=document.getElementById("c1").value;
				var c2=document.getElementById("c2").value;
				try{
					var x=divide(c1,c2);
					document.getElementById("shang").innerHTML=x;
				}catch(e){
					alert(e);
				}
			}
		</script>
	</body>

</html>